﻿
-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[proc_WebService_GetEmployeeList]
(
	@UserName VARCHAR(30),
	@Pwd VARCHAR(256)	
)
AS
BEGIN
	DECLARE @tmpPWD varchar(256)
	Set @tmpPWD = Null
	SELECT Top 1 @tmpPWD=Password FROM aspnet_Users WHERE UserName=@UserName
	If @tmpPWD Is Not Null
	BEGIN
		If Upper(@tmpPWD)=Upper(@Pwd)
			SELECT UserName,EName,isnull(ZhiWu,'') AS ZhiWu,
				ISNULL((SELECT Company.CompanyName FROM Company WHERE Company.id=Employee.CompanyId),'') AS CompanyName,
				ISNULL((SELECT Department.DName FROM Department WHERE Department.Id=Employee.DepartmentId),'') AS DepName,
				[HomePhone],[MobilePhone],[Email],[QQ]
			FROM Employee WHERE UserName=@UserName And ([State]=3 Or [State]=4) --AND CompanyId IN (1,33,34,35,36,77,72,73)
--		ORDER BY Employee.CompanyId, Employee.DepartmentId,Employee.ZhiWu,Employee.UserName
		Else
			SELECT UserName,EName,ZhiWu,'' AS CompanyName,'' AS DepName FROM Employee Where id<0
	END
	ELSE
		SELECT UserName,EName,ZhiWu,'' AS CompanyName,'' AS DepName FROM Employee Where id<0
END